package com.sunday.common.mybatis.business.annotation.utils;

import java.lang.reflect.Field;

public class ClassUtils {

    public static String buildQuery(Class<?> entityClass) {
        StringBuilder queryBuilder = new StringBuilder();

        // 使用反射获取类中的所有字段
        Field[] fields = entityClass.getDeclaredFields();
        for (Field field : fields) {
            queryBuilder.append(field.getName()).append("=?, ");
        }

        // 移除末尾多余的逗号和空格
        if (queryBuilder.length() > 0) {
            queryBuilder.setLength(queryBuilder.length() - 2);
        }

        return queryBuilder.toString();
    }

}
